﻿using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace com.fukefu.template
{
    public partial class PreviewForm : Form
    {
        private static PreviewForm mf = null;
        private static Object syncObject = new Object();

        private PreviewForm(string html)
        {
            InitializeComponent();
            //标签加红
            html = Regex.Replace(html, "{tag:[^}]+}", "<font color=red>$0</font>");
            webBrowser1.DocumentText = "<!DOCTYPE html><html><head><style type=text/css>*{margin:0;}</style></head><body>" + html + "</body></html>";
        }
        public static PreviewForm GetInstall(string html)
        {
            if (mf == null || mf.IsDisposed)
            {
                lock (syncObject)
                {
                    if (mf == null || mf.IsDisposed)
                    {
                        mf = new PreviewForm(html);
                    }
                }
            }
            return mf;
        }
    }
}
